# YunCha-Coffee PyCharm
# user 86155
# 2025/8/30 1:15
from fastapi import APIRouter
from typing import Union,List
from app.models import *
from pydantic import BaseModel, validator

user_api = APIRouter()

@user_api.get("/",summary="查询所有用户")
async def getAllStudents():
    # 查询所有
    users = await User.all()

    return {
        "message":"查询成功",
        "data":users
    }

@user_api.get("/{id}",summary="查询某一个用户")
async def getOneUser(id:int):

    user = await User.get(id=id)

    return {
        "code":200,
        "message":"查询成功",
        "data":user
    }

@user_api.post("/")
async def addUser():

    return {
        "code":200,
        "message":"添加成功"
    }

@user_api.delete("/{id}")
async def deleteUser(id:int):
    await User.filter(id=id).delete()

    return {
        "code":200,
        "message":"删除成功"
    }

@user_api.put("/{id}")
async def updateUser():

    return {
        "code":200,
        "message":"修改成功"
    }
